<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>资产入库 - 企业资产管理系统</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.1/font/bootstrap-icons.css">
    <link  rel="stylesheet" type="text/css" href="/static/css/zc.css"></head>
<body>

<!-- 头部导航 -->
<header class="header">
    <div class="logo">
        <i class="bi bi-building"></i>
        <span>企业资产管理系统</span>
    </div>
    <div class="header-right">
        <div class="notification-icon">
            <i class="bi bi-bell"></i>
            <span class="notification-badge">3</span>
        </div>
        <div class="dropdown">
            <a href="#" class="dropdown-toggle" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false">
                <img src="https://cn.bing.com/images/search?view=detailV2&ccid=OSFH3hIu&id=6E8860BEADD760736BEA422E3C9BF57317AA4F3E&thid=OIP.OSFH3hIukHqh-qrOvIfUWgAAAA&mediaurl=https%3a%2f%2fc-ssl.dtstatic.com%2fuploads%2fblog%2f202303%2f20%2f20230320145706_07ca5.thumb.400_0.jpeg&exph=498&expw=400&q=%e5%a4%b4%e5%83%8f&simid=607997774809754286&FORM=IRPRST&ck=19ACE4792BC2347CFE89D1BC55CC90F4&selectedIndex=0&itb=0" class="rounded-circle user-avatar" alt="用户头像">
                <span>管理员</span>
                <i class="bi bi-chevron-down"></i>
            </a>
            <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="userDropdown">
                <li><a class="dropdown-item" href="#"><i class="bi bi-person me-2"></i>个人信息</a></li>
                <li><a class="dropdown-item" href="#"><i class="bi bi-gear me-2"></i>系统设置</a></li>
                <li><hr class="dropdown-divider"></li>
                <li>
                    <form action="logout">
                        <a class="dropdown-item" href="#"><i class="bi bi-box-arrow-right me-2"></i>退出登录</a>
                    </form>
                </li>
            </ul>
        </div>
    </div>
</header>

<!-- 主体内容 -->
<div class="main-container">
    <!-- 侧边栏 -->
    <aside class="sidebar">
        <ul class="sidebar-menu">
            <li class="sidebar-item">
                <a href="home.jsp" class="sidebar-link">
                    <i class="bi bi-speedometer2"></i>
                    <span>控制面板</span>
                </a>
            </li>
            <li class="sidebar-item">
                <a href="Inventory_Query.jsp" class="sidebar-link active dropdown-toggle" data-bs-target="#assetMenu">
                    <i class="bi bi-laptop"></i>
                    <span>资产管理</span>
                    <i class="bi bi-chevron-down"></i>
                </a>
                <ul class="sidebar-dropdown show" id="assetMenu">
                    <li class="sidebar-item">
                        <a href="Inventory_Query.jsp" class="sidebar-link ">
                            <span>库存查询</span>
                        </a>
                    </li>
                    <li class="sidebar-item">
                        <a href="Asset_Inbound.jsp" class="sidebar-link active">
                            <span>资产入库</span>
                        </a>
                    </li>
                    <li class="sidebar-item">
                        <a href="Asset_Scrap.jsp" class="sidebar-link">
                            <span>资产报废</span>
                        </a>
                    </li>
                </ul>
            </li>

            <li class="sidebar-item">
                <a href="Maintenance_Apply.jsp" class="sidebar-link dropdown-toggle" data-bs-target="#maintenanceMenu">
                    <i class="bi bi-tools"></i>
                    <span>维修管理</span>
                    <i class="bi bi-chevron-down"></i>
                </a>
                <ul class="sidebar-dropdown collapse" id="maintenanceMenu">
                    <li class="sidebar-item">
                        <a href="Maintenance_Apply.jsp" class="sidebar-link">
                            <span>维修申请</span>
                        </a>
                    </li>
                    <li class="sidebar-item">
                        <a href="maintenance_record.jsp" class="sidebar-link">
                            <span>维修记录</span>
                        </a>
                    </li>
                    <li class="sidebar-item">
                        <a href="maintenance_statistics.jsp" class="sidebar-link">
                            <span>维修统计</span>
                        </a>
                    </li>
                </ul>
            </li>

            <li class="sidebar-item">
                <a href="user_management.jsp" class="sidebar-link dropdown-toggle" data-bs-target="#systemMenu">
                    <i class="bi bi-gear"></i>
                    <span>系统设置</span>
                    <i class="bi bi-chevron-down"></i>
                </a>
                <ul class="sidebar-dropdown collapse" id="systemMenu">
                    <li class="sidebar-item">
                        <a href="user_management.jsp" class="sidebar-link">
                            <span>用户管理</span>
                        </a>
                    </li>

                    <li class="sidebar-item">
                        <a href="Department_Management.jsp" class="sidebar-link">
                            <span>部门管理</span>
                        </a>
                    </li>

                </ul>
            </li>
        </ul>
    </aside>

    <!-- 内容区域 -->
    <main class="content">
        <h2 class="page-title">资产入库</h2>
        <div class="card">
            <div class="card-header">
                <span>资产入库登记</span>
            </div>
            <div class="card-body">
                <form>
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">资产名称</label>
                            <input type="text" class="form-control" placeholder="请输入资产名称">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">资产类别</label>
                            <select class="form-select">
                                <option>请选择资产类别</option>
                                <option>电脑设备</option>
                                <option>办公家具</option>
                                <option>网络设备</option>
                            </select>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <label class="form-label">购买日期</label>
                            <input type="date" class="form-control">
                        </div>
                        <div class="col-md-6">
                            <label class="form-label">购买价格</label>
                            <input type="number" class="form-control" placeholder="请输入购买价格">
                        </div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">备注说明</label>
                        <textarea class="form-control" rows="3" placeholder="请输入备注说明"></textarea>
                    </div>
                    <button type="submit" class="btn btn-primary">提交入库</button>
                </form>
            </div>
        </div>
    </main>
</div>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>

    // 等待DOM加载完成
    document.addEventListener('DOMContentLoaded', function() {
        // 初始化所有下拉菜单
        const dropdownElementList = [].slice.call(document.querySelectorAll('.dropdown-toggle'));
        dropdownElementList.map(function (dropdownToggleEl) {
            return new bootstrap.Dropdown(dropdownToggleEl);
        });

        // 获取所有带有dropdown-toggle类的链接
        const dropdownToggles = document.querySelectorAll('.sidebar-link.dropdown-toggle');

        // 为每个下拉菜单添加点击事件
        dropdownToggles.forEach(toggle => {
            toggle.addEventListener('click', function(e) {
                // 获取目标菜单的ID
                const targetId = this.getAttribute('data-bs-target');
                const targetMenu = document.querySelector(targetId);

                // 如果点击的是箭头图标
                if (e.target.classList.contains('bi-chevron-down') || e.target.classList.contains('bi-chevron-up')) {
                    // 阻止默认行为
                    e.preventDefault();
                    // 切换目标菜单的显示状态
                    if (targetMenu) {
                        targetMenu.classList.toggle('show');
                        // 更新箭头图标
                        const arrowIcon = this.querySelector('.bi-chevron-down, .bi-chevron-up');
                        if (arrowIcon) {
                            arrowIcon.classList.toggle('bi-chevron-down');
                            arrowIcon.classList.toggle('bi-chevron-up');
                        }
                    }
                } else {
                    // 如果点击的是链接其他部分且href不为#，则导航
                    const href = this.getAttribute('href');
                    if (href && href !== '#') {
                        window.location.href = href;
                    }
                }
            });
        });
        
        // 页面加载时自动展开资产管理菜单并选中资产入库
        const assetMenu = document.getElementById('assetMenu');
        if (assetMenu) {
            assetMenu.classList.add('show');
        }
        
        // 更新资产管理菜单的箭头图标
        const assetToggle = document.querySelector('[data-bs-target="#assetMenu"]');
        if (assetToggle) {
            const arrowIcon = assetToggle.querySelector('.bi-chevron-down, .bi-chevron-up');
            if (arrowIcon) {
                arrowIcon.classList.remove('bi-chevron-down');
                arrowIcon.classList.add('bi-chevron-up');
            }
        }
    });
</script>
<script src="/static/jq/jquery-1.4.4.min.js"></script>
<script>

    // ajax 请求
    $(function (){
        $.ajax({
            url: "/gettype",
            type: "get",
            dataType: "json",//   data:{"pageId":pageId},
            success: function (data) {
                console.log(data);
                $("#type_name").children().not(":eq(0)").remove();
                    for(var i = 0;i < data.length;i++){
                        $("#type_name").append("<option value="+data[i].id+">--"+data[i].name+"--</option>")
                    }
                }
        })

        $.ajax({
            url: "/getDept",
            type: "get",
            dataType: "json",//   data:{"pageId":pageId},
            success: function (data) {
                console.log(data);
                $("#dept_name").children().not(":eq(0)").remove();
                for(var i = 0;i < data.length;i++){
                    $("#dept_name").append("<option value="+data[i].id+">--"+data[i].name+"--</option>")
                }
            }
        })

        $.ajax({
            url: "/getDepreciate",
            type: "get",
            dataType: "json",//   data:{"pageId":pageId},
            success: function (data) {
                console.log(data);
                $("#depreciate_name").children().not(":eq(0)").remove();
                for(var i = 0;i < data.length;i++){
                    $("#depreciate_name").append("<option value="+data[i].id+">--"+data[i].depreciation_method+"--</option>")
                }
            }
        })

        $.ajax({
            url: "/getState",
            type: "get",
            dataType: "json",//   data:{"pageId":pageId},
            success: function (data) {
                console.log(data);
                $("#state_name").children().not(":eq(0)").remove();
                for(var i = 0;i < data.length;i++){
                    $("#state_name").append("<option value="+data[i].id+">--"+data[i].name+"--</option>")
                }
            }
        })
    })
</script>
</body>
</html> 